package org.aplombh.java.interview.newcoder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class HJ28_素数伴侣 {

    private static boolean[][] flag;
    private static int[] matched;
    private static boolean[] used;
    private static int res = 0;
    private static final ArrayList<Integer> odds = new ArrayList<>();
    private static final ArrayList<Integer> evens = new ArrayList<>();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int[] ints = new int[n];


        for (int i = 0; i < n; i++) {
            ints[i] = in.nextInt();
            if (ints[i] % 2 != 0) odds.add(ints[i]);
            else evens.add(ints[i]);
        }

        flag = new boolean[odds.size()][evens.size()];
        used = new boolean[evens.size()];
        matched = new int[evens.size()];  // odd -> even    i-j
        Arrays.fill(matched, -1);

        for (int i = 0; i < odds.size(); i++) {
            for (int j = 0; j < evens.size(); j++) {
                flag[i][j] = primeNumber(odds.get(i) + evens.get(j));
            }
        }

        for (int i = 0; i < odds.size(); i++) {
            Arrays.fill(used, false);
            if (find(i)) res++;
        }

        System.out.println(res);
    }

    private static boolean find(int i) {
        for (int j = 0; j < evens.size(); j++) {
            if (flag[i][j]) {
                if (!used[j]) {
                    used[j] = true;
                    if (matched[j] == -1 || find(matched[j])) {
                        matched[j] = i;
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static boolean primeNumber(int p) {
        for (int i = 2; i <= p / 2; i++) {
            if (p % i == 0)
                return false;
        }
        return true;
    }
}

